<template>
  <div>
    <chat-session-list :changeSession="changeSession"/>
    <chat-box ref="chatBox"/>
    <div class="c"></div>
  </div>
</template>

<script>
import ChatSessionList from '../Common/ChatSessionList'
import ChatBox from '../Common/ChatBox'
export default {
  name: 'ChatPage',
  components: {ChatBox, ChatSessionList},
  data:function () {
    return {
      session:{
        id:0
      }
    }
  },
  watch:{
    $route:function () {
      if (this.$route.query.sessionId){
        this.$refs.chatBox.setSession({
          id:this.$route.query.sessionId-0
        })
      }
    }
  },
  mounted() {
    if (this.$route.query.sessionId){
      this.$refs.chatBox.setSession({
        id:this.$route.query.sessionId-0
      })
    }
  },
  methods:{
    changeSession:function (session) {
      this.$refs.chatBox.setSession(session);
    }
  }
}
</script>

<style scoped>

</style>
